﻿using System.AddIn.Pipeline;
using RootfusAddinContracts;
using RootfusHostView;
using System;

namespace RootfusAddinHostAdapters
{
    [AddInAdapter]
    class PinDefinitionHostViewToContractAdapter : ContractBase, IPinDefinitionContract
    {
        PinDefinition _view;

        public PinDefinitionHostViewToContractAdapter(PinDefinition view)
        {
            _view = view;
        }

        public PinDefinition GetSourceView()
        {
            return _view;
        }

        #region IPinDefinitionContract Members

        public string Name
        {
            get { return Name; }
        }

        public RootfusAddinContracts.PinConnectionType ConnectionType
        {
            get
            {
                switch (_view.ConnectionType)
                {
                    case RootfusHostView.PinConnectionType.PinInfinite:
                        return RootfusAddinContracts.PinConnectionType.PinInfinite;
                    case RootfusHostView.PinConnectionType.PinSingle:
                        return RootfusAddinContracts.PinConnectionType.PinSingle;
                    default:
                        throw new Exception("Not Implemented!");
                }
            }
        }

        #endregion
    }
}
